interface Feedback {
  (feed: Feed): void
}

interface Module {
  config (feedback: Feedback): void
}

class Bootstrap {

  private modules: Array<Array<Module>>
  private feedback: Feedback

  constructor (feedback: Feedback) {
    this.modules = []
    this.feedback = feedback
  }

  then (...modules: Module[]) {
    this.modules.push(modules)
    return this
  }

  async bootstrap () {
    for (let modules of this.modules) {
      if (modules.length > 0) {
        let all = modules.map(module => {
          Promise.resolve(module.config(this.feedback))
            .catch(e => console.log(e.toString()))
        })
        await Promise.all(all)
      }
    }
  }
}

interface Feed {
  title: string,
  msg: string,
  status?: string
}

export { Bootstrap, Feed, Module, Feedback }
